package com.bluemson.service.Impl;

import com.bluemson.dao.ManagerDao;
import com.bluemson.entity.Comment;
import com.bluemson.entity.Plate;
import com.bluemson.service.DeleteService;
import com.bluemson.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;

public class DeleteServiceImpl implements DeleteService {
    private final SqlSession session = MyBatisUtil.getSqlSession();
    ManagerDao managerDao = session.getMapper(ManagerDao.class);
    @Override
    public void deletePlate(Plate plate){
        managerDao.deletePlate(plate);
        session.commit();
    }
    @Override
    public void deleteHost(Plate plate){
        managerDao.deleteHost(plate);
        session.commit();
    }
    @Override
    public void deleteArticle(int id){
        managerDao.deleteArticle(id);
        session.commit();
    }
    @Override
    public void deleteComment(Comment comment){
        managerDao.deleteComment(comment.getId());
        session.commit();
        managerDao.deComment(comment.getArticleId());
        session.commit();
    }
}
